package cn.ycl.system.other.study.designMode.combination;

/**
 * @author YuanChangLiang
 * @description
 * @date created in 14:26 2021/5/31
 */


public class Test {
    public static void main(String[] args) {
        Animal animal = new Animal();
        Monkey monkey = new Monkey();
        monkey.setAge(1);
        animal.setMonkey(monkey);
        animal.setName("动物");
        System.out.println("更改属性前的animal：" + animal.toString());

        Animal clone = animal.clone();
        System.out.println("更改属性前的clone：" + clone.toString());
        //clone后的对象改变属性，看被clone对象是否会跟着改变
        monkey.setAge(2);
        clone.setMonkey(monkey);
        System.out.println();
        System.out.println("clone更改属性后的clone：" + clone.toString());
        System.out.println("clone更改属性后的animal：" + animal.toString());
    }


    public void test() {
        Component boss = new Manager("老板", "抓钱");
        Component CTO = new Manager("技术主管", "管理员工");
        Component webProgrammer = new Employee("程序员", "学习设计模式");
        Component backgroundProgrammer = new Employee("后台程序员", "CRUD");
        boss.addComponent(CTO);
        CTO.addComponent(webProgrammer);
        CTO.addComponent(backgroundProgrammer);
    }

}
